/*
 * XYZTCustomNeighborhood.java
 *
 * Created on April 1, 2005, 9:10 AM
 */

package edu.temple.GUS.MMA.Neighborhoods;

import edu.temple.GUS.MMA.DataTypes.*;

/**
 *
 * @author jleong
 */
public class XYZTCustomNeighborhood extends XYZTNeighborhood{
    
    private boolean filter[][][][];

    /** Creates a new instance of XYZTCustomNeighborhood */
    public XYZTCustomNeighborhood(int x, int y, int z, int t, boolean filter[][][][])
    {
        // Define the x, y, z and t extend of the neighborhood
        super(x,y,z,t);
        this.filter = filter;
    }
    
    /** Creates a new instance of XYZTCustomNeighborhood */
    public XYZTCustomNeighborhood(MMAHyperCube filterCube)
    {
        // Define the x, y, z and t extend of the neighborhood
        super(filterCube.getX(),filterCube.getY(),filterCube.getZ(),filterCube.getT());
        
        int x = filterCube.getX();
        int y = filterCube.getY();
        int z = filterCube.getZ();
        int t = filterCube.getT();
        float noData = filterCube.getNoData();
        
        // Create a customed filter
        filter = new boolean[t][z][y][x];
        
        for (int l=0; l<t; l++)
            for (int k=0; k<z; k++)
                for (int j=0; j<=y; j++)
                    for (int i=0; i<=x; i++)
                    {
                        if ( filterCube.getElement(i,j,k,l) == noData )
                            filter[l][k][j][i] = false;
                        else
                            filter[l][k][j][i] = true;
                    }
    }

    public boolean getFilterElement(int x, int y, int z, int t) { return filter[t][z][y][x];}
}
